<?php

require_once 'db.class.php';

class Message extends Db
{
	public $tbname = 'message';

	function submit($arr)
	{
		if($this->checkmsg($arr))
		{
			return $this->checkmsg($arr);
		}else{
			return $this->_insert($arr) ? 1 : 5;
		}
	}

	function checkmsg($arr)
	{
		$this->sql = "select * from message where ip= '".$arr['ip']."' and date(addtime) = curdate()";
		$result = $this->dosql('_select');
		if(count($result)==3)
		{
			return 4;//当天提交次数已满
		}elseif($result &&($result[0]['message']==$arr['message'] || $result[1]['message']==$arr['message'])){
			return 3;//已存在勿重复提交
		}
		return null;
	}
}

?>